package cn.buk.tms.eotms.config;

import cn.buk.api.pay.alipay.service.AlipayService;
import cn.buk.api.pay.alipay.service.AlipayServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
 *
 * @author yfdai
 */
@Configuration
@PropertySource(value="classpath:config.properties")
@ComponentScan(basePackages = {"cn.buk"},
        excludeFilters = {
            @ComponentScan.Filter(type= FilterType.ANNOTATION, value = EnableWebMvc.class)
        })
public class RootConfig {

  @Bean
  public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
  }

  @Value("${alipay_notify_url}")
  private String notifyUrl;

  @Value("${alipay_return_url}")
  private String returnUrl;

  @Value("${alipay_appid}")
  private String appId;

  @Value("${alipay_private_key}")
  private String privateKey;

  @Value("${alipay_public_key}")
  private String publicKey;

  @Bean
  public AlipayService createAlipayService() {
    return new AlipayServiceImpl(appId, privateKey, publicKey, notifyUrl, returnUrl);
//    return new AlipayServiceImpl(AlipayConfig.appId,
//            AlipayConfig.privateKey,
//            AlipayConfig.publicKey,
//            AlipayConfig.notifyUrl,
//            AlipayConfig.returnUrl);
  }
}
